<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function round(){
            var value = parseInt(document.getElementById("txt").value);
            if (value || value==0){
                alert(Math.floor(value));
            }else{
                alert("不是整数")
            }
        }
        function round2(){
            var value = parseInt(document.getElementById("txt").value);
            if (value || value==0){
                alert(Math.floor(value*value));
            }else{
                alert("不是整数")
            }
        }
    </script>
</head>
<body>

<input type="text" id="txt">
<input type="button" value="ok" onclick="round()">
<input type="button" value="平方" onclick="round2()">
</body>
</html>